<div class="container">
  <ol class="breadcrumb">
    <li><%= link_to 'Home', root_path %></li>
    <li><%= link_to 'Organizations', orgs_path %></li>
    <li class="active">Organization</li>
  </ol>
</div>

<%= render 'info' %>

<div class="container">
  <h3>
    All created groups
    <% if session[:org_id] == params[:id].to_s %>
        <a href="<%= new_group_user_path %>" class="btn btn-success"> <span class="glyphicon glyphicon-upload"></span> Create a
          group</a>
    <% end %>
  </h3>


  <br/>

  <div class="media">
    <% if @group_users.empty? %>
        <div class="alert alert-warning">
          Currently no groups are created with this organization.
        </div>
    <% else %>

        <table class="table table-hover">
          <thead>
          <tr>
            <th>#</th>
            <th>Title</th>
            <th>Detail</th>

            <th colspan="3"></th>
          </tr>
          </thead>

          <tbody>
          <% i = 1 %>
          <% @group_users.each do |group_user| %>
              <tr>
                <td><%= i %></td>
                <td><%= group_user.title %></td>
                <td><%= group_user.detail %></td>
                <% if session[:org_id] == params[:id].to_s %>
                    <td><%= link_to 'Show', group_user, :class => "btn btn-xs btn-default" %></td>
                    <td><%= link_to 'Edit', edit_group_user_path(group_user), :class => "btn btn-xs btn-warning" %></td>
                    <td><%= link_to 'Destroy', group_user, method: :delete, :class => "btn btn-xs btn-danger", data: {confirm: 'Are you sure?'} %></td>
                <% end %>
              </tr>
              <% i = i + 1 %>
          <% end %>
          </tbody>
        </table>

    <% end %>
  </div>
</div>